import React from 'react';
import { Card } from 'antd/lib/index';
import ApiTubro from '@/components/Engineering/ApiTubro';
import QuickTool from '@/components/Engineering/QuickTool';
import ETable from '@/components/Engineering/ETable';
import Utils from '@/components/Engineering/utils';

import { PageHeaderWrapper } from '@ant-design/pro-layout/lib/index';
import { connect } from 'dva/index';

@connect(({ loading, searchList }) => ({
  searchList,
  loading: loading.models.rule,
}))
export default class SeaTransport extends React.Component {
  state = {};
  page = {};
  expand = false;

  componentDidMount() {
    this.getListForPage();
  }

  getListForPage = params =>
    ApiTubro.getListForPage.bind(this)({
      url: `${PORTAL_PATH}/api/pj/apply`,
      data: this.page,
    });

  Columns = [
    {
      title: '申请单号',
      dataIndex: 'outTradeNo',
      key: 'outTradeNo',
    },
    {
      title: '产品名称',
      dataIndex: 'productName',
      key: 'productName',
    },
    {
      title: '联系人',
      dataIndex: 'applicant',
      key: 'applicant',
    },
    {
      title: '电话',
      dataIndex: 'phone',
      key: 'phone',
    },
    {
      title: '地址',
      dataIndex: 'flowName',
      key: 'flowName',
    },
    {
      title: '状态',
      dataIndex: 'status',
      key: 'status',
      render: text => {
        if (text == '0') {
          text = '删除';
        } else if (text == '1') {
          text = '正常';
        } else if (text == 'WSQ') {
          text = '未授权';
        } else if (text == 'YSQ') {
          text = '已授权';
        } else if (text == 'YHE') {
          text = '已核额';
        } else if (text == 'YSQ') {
          text = '已放款';
        } else if (text == 'YBJ') {
          text = '已被拒';
        } else if (text == 'WTGBMD') {
          text = '未通过白名单';
        } else if (text == 'YZF') {
          text = '已作废';
        } else if (text == 'YBJ') {
          text = '已退件';
        } else {
          text = 'UNKNOWN';
        }
        return text;
      },
    },

    {
      title: '贷款进度',
      dataIndex: 'loanStatus',
      key: 'loanStatus',
      render: text => {
        if (text == 'WSQ') {
          text = '未授权';
        } else if (text == 'YSQ') {
          text = '已授权';
        } else if (text == 'YHE') {
          text = '已核额';
        } else if (text == 'YFK') {
          text = '已放款';
        } else if (text == 'YBJ') {
          text = '已被拒';
        } else if (text == 'WTGBMD') {
          text = '未通过白名单';
        } else if (text == 'YZF') {
          text = '已作废';
        }
        return text;
      },
    },
    {
      title: '申请时间',
      dataIndex: 'createTime',
      key: 'createTime',
    },
  ];

  render() {
    return (
      <PageHeaderWrapper title="外贸信用贷记录">
        <Card>
          <div className="content-wrap">
            <ETable
              columns={this.Columns}
              updateSelectedItem={Utils.updateSelectedItem.bind(this)}
              selectedRowKeys={this.state.selectedRowKeys}
              dataSource={this.state.pageListData}
              pagination={this.state.pagination}
            />
          </div>
        </Card>
      </PageHeaderWrapper>
    );
  }
}
